+2008-07-06 Matthias Clasen <mclasen@redhat.com>
+
+ Bug 541645 – gtkfilechooserdefault segfaults when bookmark does not
+ contain ://
+
+ * gtk/gtkfilechooserdefault.c (_gtk_file_chooser_label_for_file):
+ Be more robust. Reported by Jelte van der Hoek
+
2008-07-06 Matthias Clasen <mclasen@redhat.com>
Bug 540917 – deprecate pack_start_defaults()
uri = g_file_get_uri (file);
start = strstr (uri, "://");
- start += 3;
- path = strchr (start, '/');
-
- if (path)
- end = path;
- else
+ if (start)
{
- end = uri + strlen (uri);
- path = "/";
- }
+ start += 3;
+ path = strchr (start, '/');
+ if (path)
+ end = path;
+ else
+ {
+ end = uri + strlen (uri);
+ path = "/";
+ }
- /* strip username */
- p = strchr (start, '@');
- if (p && p < end)
- {
- start = p + 1;
- }
+ /* strip username */
+ p = strchr (start, '@');
+ if (p && p < end)
+ start = p + 1;
- p = strchr (start, ':');
- if (p && p < end)
- end = p;
+ p = strchr (start, ':');
+ if (p && p < end)
+ end = p;
- host = g_strndup (start, end - start);
-
- /* Translators: the first string is a path and the second string
- * is a hostname. Nautilus and the panel contain the same string
- * to translate.
- */
- label = g_strdup_printf (_("%1$s on %2$s"), path, host);
+ host = g_strndup (start, end - start);
+
+ /* Translators: the first string is a path and the second string
+ * is a hostname. Nautilus and the panel contain the same string
+ * to translate.
+ */
+ label = g_strdup_printf (_("%1$s on %2$s"), path, host);
+
+ g_free (host);
+ }
+ else
+ {
+ label = g_strdup (uri);
+ }
- g_free (host);
g_free (uri);
return label;